package se.zens.demo.wsapp.interfaces;

import javax.ws.rs.DELETE;
import javax.ws.rs.FormParam;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;

/**
 * RESTful WS interface for maintaining customer information
 * The publish part is configurable in wsapp.properties
 * By default it is published with path localhost:8500/customerservice/
 */

public interface CustomerService
{
	/**
	 * Ping method is supposed to use for checking if the service is running.
	 * <p>URL: localhost:8500/customerservice/ping/
	 * <p>HTTP Method: GET 
	 * @return 200:OK with "pong" plain text
	 */
	@GET
	@Path("/ping/")
	@Produces({"plain/text"})
	String ping();
	
	/**
	 * Retrive customer with specific id
	 * <p>URL: localhost:8500/customerservice/get/{id}
	 * <p>HTTP Method: GET 
	 * @param id
	 * @return 200:OK with Customer JSon object
	 * <p>204:No content if there is no customer
	 *
	 * 
	 */
    
	@GET
	@Path("/get/{id}/")
	@Produces({ MediaType.APPLICATION_JSON })
	Response getCustomer(@PathParam("id") String id);
	
	/**
	 * Retrieve all customers
	 * <p>URL: localhost:8500/customerservice/get/
	 * <p>HTTP Method: GET 
	 * @return 200:OK with all customers json objects 
	 * <p>204:No content if there is no customer
	 */
    @GET
	@Path("/get/")
    @Produces({ MediaType.APPLICATION_JSON })
	Response getAll();
 
    /**
	 * Add new customer
	 * <p>URL: localhost:8500/customerservice/add/
	 * <p>HTTP Method: POST 
	 * <p>Remark: Since it is a POST method so the request need to have content-type as 'application/x-www-form-urlencoded'
	 * @param id
	 * @param name
	 * @return 200:OK with added customer json objects 
	 * <p>204:No content if id is empty
	 * <p>204:No content if customer list is empty
	 * 
	 */
	@POST
	@Path("/add/")
	@Produces({ MediaType.APPLICATION_JSON })
	Response addCustomer(@FormParam("id") String id,@FormParam("name") String name);

	/**
	 * Update existing customer
	 * <p>URL: localhost:8500/customerservice/set/
	 * <p>HTTP Method: PUT 
	 * <p>Remark: Since it is a PUT method so the request need to have content-type as 'application/x-www-form-urlencoded'
	 * @param id
	 * @param name
	 * @return 200:OK with updated customer json objects 
	 * <p>204:No content if id is empty
	 * <p>204:No content if there is no customer in the list
	 * <p>304:Not modified if customer not found
	 * 
	 */
	@PUT
	@Path("/set/")
	@Produces({ MediaType.APPLICATION_JSON})
	Response updateCustomer(@FormParam("id") String id,@FormParam("name") String name);


	/**
	 * Delete existing customer
	 * <p>URL: localhost:8500/customerservice/del/
	 * <p>HTTP Method: DELETE 
	 * 
	 * @param id
	 * @return 200:OK 
	 * <p>204:No content if id is empty
	 * <p>204:No content if there is no customer in the list
	 * <p>304:Not modified if customer not found
	 * 
	 */
	@DELETE
	@Path("/del/")
	Response deleteCustomer(@FormParam("id") String id);

}
